import Instance from "../Utils/request.js";
import path from "./path";

const api = {
    //#region 关于解析jwt令牌
    ParseJwt(token) {
        return Instance.get(path.baseUrl + `/common/ParseJwt/${token}`)
    },

    //#endregion
    
    //#region 用户
    // 用户信息
    selectUserInCondition(userDTO){
        return Instance.post(path.baseUrl + "/user/selectUserInCondition",userDTO)
    },

    // 用户登录
    UserLogin(userLorR_DTO) {
        return Instance.post(path.baseUrl + "/user/login", userLorR_DTO)
    },
    //#endregion


    //#region 房间
    
    // 房间信息
    getAllRoomInPage(InputCurrent=null, InputSize=null){
        
        if(InputCurrent==null, InputSize==null){
            InputCurrent = 1;
            InputSize = 10
        }
        return Instance.get(path.baseUrl + "/room/getAllRoomInPage",{
            params: {
                current: InputCurrent,
                size: InputSize
            }
        })
    },

    // 根据id查询房间信息
    getRoomByIds(ids) {
        if(Array.isArray(ids)){
            ids = ids.join(",")
        }
        return Instance.get(path.baseUrl + "/room/getRoomByIds", {
            params: {
                ids
            }
        })
    },

    // 根据条件查询房间信息
    getRoomInCondition(roomDTO){
        return Instance.post(path.baseUrl + "/room/getRoomInCondition",roomDTO)
    },


    // 查全部房间类型
    findRoomType(){
        return Instance.get(path.baseUrl + "/RoomType/findRoomType")
    },

    // 根据条件查房间类型
    findRoomTypeInCondition(RoomTypeDTO){
        return Instance.post(path.baseUrl + "/RoomType/findRoomTypeInCondition",RoomTypeDTO)
    },

    // 添加订单
    addOrder(ordersDTO){
        return Instance.post(path.baseUrl + "/orders/addOrder",ordersDTO)
    },

    //#endregion 

    

    // 订单信息
    getOrderInCondition(OrdersDTO){
        return Instance.post(path.baseUrl + "/orders/getOrderInCondition",OrdersDTO)
    },

    // 评论信息
    getUserReviewsInCondition(UserReviewsDTO){
        return Instance.post(path.baseUrl + "/user-reviews/getUserReviewsInCondition",UserReviewsDTO)
    }
}

export default api;
